import React from 'react'
import { useLocation, useParams } from 'react-router-dom'
import qs from 'qs'
export default function News() {
  const location = useLocation()
  const { user } = qs.parse(location.search.split('?')[1])
  const { id } = useParams()
  const { state } = location
  return (
    <div>
      <h1>News</h1>
      <p>用户名：{user} 用户id:{id}</p>
      <ul>
           {
            state.map(item=>{
              return <li key={item.id}>{item.name}</li>
            })
        }
        </ul>
    </div>
  )
}